package com.coder.books.thinkinjava.enumerated.menu;

import com.coder.util.Enums;

import static com.coder.util.Print.println;

/**
 * 菜品
 *
 * @author yuhushuan
 * @date 2020/9/6 12:06
 */
public enum Course {
    APPETIZER(Food.Appetizer.class),
    MAINCOURSE(Food.MainCourse.class),
    DESSERT(Food.Dessert.class),
    COFFEE(Food.Coffee.class);

    private Food[] values;

    private Course(Class<? extends Food> kind) {
        values = kind.getEnumConstants();
    }

    public Food randomSelection() {
        return Enums.random(values);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            for (Course course : Course.values()) {
                Food food = course.randomSelection();
                println(food);
            }
            println("=====");
        }

    }
}
